<template>
  <div id="app-body">
      <!-- 积分等级列表 -->
      <el-table
        :data="integralGradeList"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column align="center" label="id" width="180" prop="id" />
        <el-table-column
          align="center"
          label="起始积分"
          width="180"
          prop="integralStart"
        />
        <el-table-column align="center" label="末尾积分" width="180" prop="integralEnd" />
        <el-table-column
          align="center"
          label="借款额度"
          width="180"
          prop="borrowAmount"
        />
        <el-table-column align="center" label="创建时间" width="180" prop="createTime" />
        <el-table-column align="center" label="修改时间" width="180" prop="updateTime" />
        <el-table-column align="center" label="操作">
          <template slot-scope="scope">
            <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
              >编辑</el-button
            >
            <el-button
              size="mini"
              type="danger"
              @click="handleDelete(scope.$index, scope.row)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
  </div>
</template>

<
<script>
import integralGradeApi from "@/api/core/integral_grade";

export default {
  data() {
    return {
      integralGradeList: [],
    };
  },

  created() {
    this.getAllIntegralGrade();
  },

  methods: {
    getAllIntegralGrade() {
      integralGradeApi.getIntegralGradeList().then((resp) => {
        this.integralGradeList = resp.data.list;
      });
    },

    handleSelectionChange(val) {},

    handleDelete(index, row) {
      if (row && row.id) {
        this.$confirm("此操作将永久删除该等级, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }).then(() => {
            integralGradeApi.removeById(row.id).then((resp) => {
              this.$message({ type: "success", message: resp.message });
            });
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消删除",
            });
          });
      }
    },

    handleEdit(index, row) {
        this.$router.push("/core/integral_grade/edit/" + row.id)
    }
  },
};
</script>

<style></style>
